package com.artPreter.service.impl;


import com.artPreter.mapper.EventExhibitionMapper;
import com.artPreter.pojo.EventExhibition;
import com.artPreter.service.IEventExhibitionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 活动展览表 服务实现类
 * </p>
 *
 * @author jarvis
 * @since 2025-01-05
 */
@Service
public class EventExhibitionServiceImpl extends ServiceImpl<EventExhibitionMapper, EventExhibition> implements IEventExhibitionService {



    @Override
    public EventExhibition getEventExhibitionByInfo(Integer id) {
        EventExhibition eventExhibition = this.baseMapper.selectById(id);
        return eventExhibition;
    }

    @Override
    public IPage<EventExhibition> getDepartRelatedEventExhibitionPageList(EventExhibition eventExhibition, Integer currentPage) {
        IPage<EventExhibition> eventExhibitionIPage = new Page<>(currentPage,10);
        String contentId = eventExhibition.getContentId();
        QueryWrapper<EventExhibition> eventExhibitionQueryWrapper = new QueryWrapper<>();
        eventExhibitionQueryWrapper.eq("s.content_id", contentId);
        eventExhibitionQueryWrapper.eq("b.status",1);
        eventExhibitionQueryWrapper.orderByDesc("b.create_date");
        eventExhibitionIPage = this.baseMapper.getDepartRelateEventExhibitionPageList(eventExhibitionIPage,eventExhibitionQueryWrapper);
        return eventExhibitionIPage;
    }

    @Override
    public IPage<EventExhibition> getPage(EventExhibition eventExhibition, Integer currentPage) {
        IPage<EventExhibition> eventExhibitionIPage = new Page<>(currentPage,10);
        QueryWrapper<EventExhibition> eventExhibitionQueryWrapper = new QueryWrapper<>();
        eventExhibitionQueryWrapper.eq("status",1);
        eventExhibitionQueryWrapper.orderByDesc("create_date");
        if(eventExhibition.getArtistIds()!=null&&!eventExhibition.getArtistIds().equals("")){
            eventExhibitionQueryWrapper.like("artist_ids",eventExhibition.getArtistIds());
        }
        eventExhibitionIPage = this.baseMapper.selectPage(eventExhibitionIPage,eventExhibitionQueryWrapper);
        return eventExhibitionIPage;
    }
}
